package com.gpStudy.Netty.rpc.consumer;

import com.gpStudy.Netty.rpc.api.IRpcHelloService;
import com.gpStudy.Netty.rpc.api.IRpcService;
import com.gpStudy.Netty.rpc.consumer.proxy.RpcProxy;
import com.gpStudy.Netty.rpc.provider.RpcHelloServiceImpl;
import com.gpStudy.Netty.rpc.provider.RpcServiceImpl;

public class RpcConsumer {

    public static void main(String[] args) {

        // 本地调用示例
//        IRpcService service = new RpcServiceImpl();
//        System.out.println("8+2=" + service.add(8, 2));
//
//        IRpcHelloService service1 = new RpcHelloServiceImpl();
//        System.out.println(service1.hello("Tom"));

        // 远程调用
        IRpcService rpcService = RpcProxy.create(IRpcService.class);
        System.out.println("8+2=" + rpcService.add(8, 2));

        IRpcHelloService rpcService1 = RpcProxy.create(IRpcHelloService.class);
        System.out.println(rpcService1.hello("Tom"));

    }
}
